package main

import (
	"fmt"
)

type ListNode struct {
	Val  int
	Next *ListNode
}

func main() {
	list1_head := &ListNode{Val: 1, Next: &ListNode{Val: 2, Next: &ListNode{Val: 3, Next: nil}}}
	list2_head := &ListNode{Val: 4, Next: &ListNode{Val: 2, Next: &ListNode{Val: 3}}}
	len1 := 0
	len2 := 0
	current_list1 := list1_head
	for current_list1 != nil {
		current_list1 = current_list1.Next
		len1++
	}
	current_list2 := list2_head
	for current_list2 != nil {
		current_list2 = current_list2.Next
		len2++
	}
	point := 0
	if len1 > len2 {
		point = len1 - len2
		for list1_head != nil && point > 0 {
			list1_head = list1_head.Next
			point--
		}
		fmt.Println(list1_head.Val)
	} else if len1 < len2 {
		point = len2 - len1
		for list2_head != nil && point > 0 {
			list2_head = list2_head.Next
			point--
		}
		fmt.Println(list2_head.Val)
	} else {
		fmt.Println("error")
	}

}
